package com.example.Custom;

import com.example.weatherforcast.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class LocationCity extends LinearLayout{
	public LocationCity(Context context) {
		this(context, null); 
	}
	public LocationCity(Context context, AttributeSet attrs) {
		super(context, attrs);
		View view=LayoutInflater.from(context).inflate(R.layout.customcity,this, true);
		tv_customcity=(TextView) findViewById(R.id.tv_customcity);
		iv_customcity=(ImageView) findViewById(R.id.iv_customcity);
//		if (text==null) {
//			text="";
//		}
	//	this.addView(view);
	}


	private int src;
	private String text;
	private TextView tv_customcity;
	private ImageView  iv_customcity;
	

	public int getSrc() {
		return src;
	}


	public void setSrc(int src) {
		this.src = src;
		iv_customcity.setImageResource(src);
	//	invalidate();
	}


	public String getText() {
		return text;
	}


	public void setText(String text) {
		this.text = text;
		tv_customcity.setText(text);
		//invalidate();
	}



		
		
		
//		TypedArray array=context.obtainStyledAttributes(attrs, R.styleable.location);
//		text=array.getString(R.styleable.location_android_text);
//		
//		src=array.getResourceId(R.styleable.location_android_src,R.drawable.ic_launcher );
//		if (text==null) {
//			text="定位";
//		}
//		tv_customcity.setText(text);
//		iv_customcity.setImageResource(src);
//		
//		array.recycle();//回收typedArray

}
